/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package RMI;

import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author TNT
 */
public class Client {
    public Connect_interface obj;
   
    public boolean Connect(){
        boolean connect = false;
         String url = "rmi://localhost:1099/Demo";
        System.out.println(url);
        try {
            
            obj = (Connect_interface)Naming.lookup("Demo");
            System.out.println("Ket noi thanh cong");
            connect = true;
        } catch (Exception ex) {
           
            connect = false;
        }
        return connect;
    }
    public String[] getAllProduct(){
        String SP[] = null;
        try{
            SP = obj.getAllProduct();
            System.out.println(SP.length); 
        }
        catch(Exception ex){}   
       
        return SP;
        
    }
    public String[] LaySP(){
        String SP[] = new String[9];
        try{
            SP = obj.getProduct();
            
        }
        catch(Exception ex){}   
        System.out.println(SP.length);
        return SP;
        }
   public void addHelp(String email, String name, String question){
       try{
           obj.addHelp(email, name, question);
       }
       catch(Exception ex){
           
       }
   }
   public void editProduct(String id, String name, String provider, String cost, String detail,String state){
       try{
           
       }
       catch(Exception ex){}
   }
   public String[] getProductDetail(String id){
       String Prd[] = new String[6];
       try{
           Prd = obj.getProductDetail(id);
       }
       catch(Exception ex){}
       return Prd;
   }
   public String checkAdmin(String id, String password){
       String Admin=null;
       try{
           Admin = obj.checkAdmin(id, password);
       }
       catch(Exception ex){}
       return Admin;
   }
   public String[] searchProduct(String name, String provider, String cost){
       String Prd[] = null;
       try{
           Prd=obj.searchProduct(name, provider, cost);
           return Prd;
       }
       catch(Exception ex){}
       return Prd;
   }
   public String[] seacrhProduct(String keyword){
       
       try{
           String Prd[]= obj.searchProduct(keyword);
           return Prd;
       }
       catch(Exception ex){}
       return null;
   }
}
